/**
 * @file:     main.c
 * @Author:   ChenBlue
 * @email:    ChenBlue952@qq.com
 * @data:     2023年03月12日 星期日 15时42分05秒
 * @brief:
 */

#include "lv_port.h"
#include "lvgl/lvgl.h"
#include "lvgl/lv_demos.h"
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <weather.h>

#ifdef CONFIG_ADAPTOGUI
#include "adaptogui.h"
#endif

#define LVGL_TICK 10

void run_demos()
{
#if LV_USE_DEMO_WIDGETS
	lv_demo_widgets();
	printf("success: lv_demo_widgets()\n");
#elif LV_USE_DEMO_MUSIC
	lv_demo_music();
	printf("success: lv_demo_music()\n");
#elif LV_USE_DEMO_MULTILANG
	lv_demo_multilang();
	printf("success: lv_demo_multilang()\n");
#elif LV_USE_DEMO_STRESS
	lv_demo_stress();
	printf("success: lv_demo_stress()\n");
#elif LV_USE_DEMO_KEYPAD_AND_ENCODER
	lv_demo_keypad_encoder();
	printf("success: lv_demo_keypad_encoder()\n");
#elif LV_USE_DEMO_FLEX_LAYOUT
	lv_demo_flex_layout();
	printf("success: lv_demo_flex_layout()\n");
#elif LV_USE_DEMO_TRANSFORM
	lv_demo_transform();
	printf("success: lv_demo_transform()\n");
#elif LV_USE_DEMO_SCROLL
	lv_demo_scroll();
	printf("success: lv_demo_scroll()\n");
#elif LV_USE_DEMO_VECTOR_GRAPHIC && LV_USE_VECTOR_GRAPHIC
	lv_demo_vector_graphic();
	printf("success: lv_demo_vector_graphic()\n");
#elif LV_USE_DEMO_BENCHMARK
	lv_demo_benchmark();
	printf("success: lv_demo_benchmark()\n");
#endif
}

int main()
{
	printf("hello yctek!\n");

	lv_init();
	printf("success: lv_init()\n");

	lv_port_disp_init();
	printf("success: lv_port_disp_init()\n");

	lv_port_indev_init();
	printf("success: lv_port_indev_init()\n");

#ifdef CONFIG_ADAPTOGUI
	adaptogui_main();
#endif

	run_demos();
	printf("success: run_demos()\n");

	while (!lv_port_indev_quit()) {
		lv_port_indev_event_poll();

		lv_tick_inc(LVGL_TICK);
		lv_timer_handler();
		usleep(LVGL_TICK * 1000);
	}

	return 0;
}
